﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SMA.GENTEv1.Dados;

namespace SMA.GENTEv1
{
    public class StatusConfiguracaoWorkflow
    {
        #region Variaveis Membro
        private int _idStatusConfiguracaoWorkflow;
        private string _descricao;
        private GENTEEntities _context;
        #endregion

        #region Propriedades
        public int IdStatusConfiguracaoWorkflow
        {
            get { return _idStatusConfiguracaoWorkflow; }
            set { _idStatusConfiguracaoWorkflow = value; }
        }
        public string Descricao
        {
            get { return _descricao; }
            set { _descricao = value; }
        }
        #endregion

        #region Construtores
        public StatusConfiguracaoWorkflow()
        {
            try
            {
                _context = new GENTEEntities();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public StatusConfiguracaoWorkflow(int idStatusConfiguracaoWf)
        {
            try
            {
                _context = new GENTEEntities();
                Carregar(idStatusConfiguracaoWf);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion

        #region Metodos Privados
        private void Carregar(int idStatusConfiguracaoWf)
        {
            try
            {
                var consulta = from s in _context.tab_status_configuracao_workflow
                               where s.id_status_configuracao_workflow == idStatusConfiguracaoWf
                               select s;

                var listConsulta = consulta.ToList();

                foreach (var list in listConsulta)
                {
                    this._idStatusConfiguracaoWorkflow = list.id_status_configuracao_workflow;
                    this._descricao = list.descricao;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion

        #region Metodos Publicos

        #region Metodos Publicos - Pesquisa
        public List<StatusConfiguracaoWorkflow> SelectAll()
        {
            try
            {
                List<StatusConfiguracaoWorkflow> listStatus = new List<StatusConfiguracaoWorkflow>();

                var consulta = from s in _context.tab_status_configuracao_workflow
                               select s;

                var listConsulta = consulta.ToList();

                foreach (var list in listConsulta)
                {
                    StatusConfiguracaoWorkflow status = new StatusConfiguracaoWorkflow();
                    status.IdStatusConfiguracaoWorkflow = list.id_status_configuracao_workflow;
                    status.Descricao = list.descricao;

                    listStatus.Add(status);
                }

                return listStatus;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion

        #region Metodos Publicos - Persistencia
        #endregion

        #endregion

        

        
    }
}
